module ex1_fbctl_lsm(
  input  [15:0] i_lsm_reglist,
  input  [ 4:0] i_lsm_offset,
  input         i_valid,
  input         i_rf_we0,
  input         i_up,
  output        o_fb,
  output        o_pc_we,
  output [15:0] o_lsm_reglist,
  output [ 4:0] o_lsm_offset,
  output        o_rf_we0
);

assign o_fb = |o_lsm_reglist;
assign o_lsm_reglist = i_lsm_reglist & (i_lsm_reglist-16'b1);
assign o_lsm_offset = i_up ? i_lsm_offset + 5'b1 : i_lsm_offset - 5'b1;
assign o_pc_we = i_valid & ~o_fb;
assign o_rf_we0 = i_rf_we0 & ~|o_lsm_reglist;

endmodule
